package com.shujia.controller;


//import org.springframework.stereotype.Controller;

import com.shujia.entity.Beans;
import com.shujia.entity.Emp;
import com.shujia.service.Hello;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.*;

//@Controller
@RestController
public class TestController {

    @Value("${name}")
    private String name;

    @Value("${age}")
    private Integer age;

    @Value("${flag}")
    private Boolean flag;

    @Value("${price}")
    private Double price;

    @Value("${bir}")
    private Date bir;

    @Value("${shuzu}")
    private String[] shuzu;

    @Value("${list}")
    private List<String> list;

    @Value("#{${map}}")
    private Map<String,String> map;

    @Autowired
    private Emp emp;


    @Autowired
    private Hello hello;

    @Autowired
    private Beans beans;


    //http/https://dadsa/hello
    //localhost:8080/hello
    @RequestMapping("hello")
    public String sayHello() {
        Calendar calendar = beans.calendar();

        Date date = calendar.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String s = sdf.format(date);

        System.out.println(name+","+age+","+flag+","+price+","+bir);
        hello.sayHello();
        return "欢迎大家来到数加学院！！" + s+"\n"+name+","+age+","+flag+","+price+","+bir+","+ Arrays.toString(shuzu)
                +list+map;
    }

    @RequestMapping("emptest")
    public String testEmp(){
        return emp.getIno()+","+emp.getEname()+","+emp.getSal();
    }

    //...
}
